<!-- 模板继承 -->
{extend name="public:base" /}

<!-- 页面标题 -->
{block name="title"}Administrator{/block}

<!-- 自定义css -->
{block name="css"}{/block}

<!-- 内容区域 -->
{block name="content"}

        <form role="form" id="operate">
            <div class="row">
                <div class="col-md-12">
                    <div class="box box-solid no-border">
                        <!-- /.box-header -->
                        <div class="box-body">
                            <div class="form-group">
                              <label>{:lang('SMS')} <span class="text-red">*</span></label>
                              <div class="row">
                              <div class="col-md-2">
                                <select name="sms_type" class="form-control">
                                    <option {eq name="sms_type" value="dysms"}selected{/eq} value="dysms">阿里云短信</option>
                                </select>
                              </div>
                              </div>
                            </div>
                                <div class="form-group">
                                  <label>AccessKey ID</label>
                                  <div class="row">
                                  <div class="col-md-4">
                                  <input type="text" name="ali_access_key" value="{$ali_access_key}" class="form-control input-sm" placeholder="">
                                  </div>
                                  </div>
                                </div>
                                <div class="form-group">
                                  <label>Access Key Secret</label>
                                  <div class="row">
                                  <div class="col-md-4">
                                  <input type="text" name="ali_access_key_secret" value="{$ali_access_key_secret}" class="form-control input-sm" placeholder="">
                                  </div>
                                  </div>
                                </div>
                                <div class="form-group">
                                  <label>{:lang('Sign')}</label>
                                  <div class="row">
                                  <div class="col-md-4">
                                  <input type="text" name="ali_sign_name" value="{$ali_sign_name}" class="form-control input-sm" placeholder="">
                                  </div>
                                  </div>
                                </div>
                                <div class="form-group">
                                  <label> {:lang('Template ID')}</label>
                                  <div class="row">
                                  <div class="col-md-4">
                                  <input type="text" name="ali_template_code" value="{$ali_template_code}" class="form-control input-sm" placeholder="">
                                  </div>
                                  </div>
                                </div>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <div class="btn-group">
                                <button class="btn btn-primary btn-flat" onclick="operate();" type="button"> {:lang('Save')}</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </form>
{/block}

<!-- 自定义js -->
{block name="js"}
<script type="text/javascript">

    // 选择上传方式
    (function (){
        var type = $('[name="upload_type"]');
        var selected = $('option:selected').val();
        setActive(selected)

        type.change(function(){
            setActive(type.val());

        })

        function setActive(selected) {
            switch(selected){
                case 'local':
                    $('[href="#tab_1"]').tab('show');
                break;
                case 'alioss':
                    $('[href="#tab_2"]').tab('show');
                break;
                case 'qiniuoss':
                    $('[href="#tab_3"]').tab('show');
                break;
            }
        }
    }());


    function operate(){
        $.ajax({
            url:"{:url('admin/site/sms')}",
            data:$("#operate").serialize(),
            type:'post',
            dataType:'json',
            success:function(xhr){
                if(xhr.code == 200){
                    swal({
                      position: 'center',
                      type: 'success',
                      title: xhr.msg,
                      showConfirmButton: false,
                      toast:false,
                      timer: 2000
                    });
                } else{
                    swal({
                      position: 'center',
                      type: 'error',
                      title: xhr.msg,
                      showConfirmButton: false,
                      toast:false,
                      timer: 2000
                    });
                }
            }
        });
    }

</script>
{/block}